This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.
\nplot(x^2,-2,2)
or plot(x^2,xmin=-2,xmax=2)
.
︡980a1956-e3c4-47d7-9eaf-925159c3cffe︡{"done":true,"html":"\nplot(x^2,-2,2)
or plot(x^2,xmin=-2,xmax=2)
."}
︠7114bdd4-6beb-4d39-84f7-52d1885649b4s︠
plot(x^2,(x,-2,2))
︡5cc0ed96-6dcb-4260-97ac-3c22b336d6cb︡{"file":{"filename":"/projects/a717257b-7b34-4f0a-bccc-47996d6ed607/.sage/temp/compute7-us/17920/tmp_1ALN8I.svg","show":true,"text":null,"uuid":"4629ee03-e3d8-496c-b1e5-f0205b655ca5"},"once":false}︡{"done":true}︡
︠891cf39b-2acb-41cd-8dd3-8e9484403d7ci︠
%html
You can combine graphics object by adding them.
︡8808cb04-f33c-4396-8e70-9c47513fe5e2︡{"done":true,"html":"\nYou can combine graphics object by adding them."}
︠6ef3a1fc-202d-404b-9a8c-26f03f49c909s︠
regular = plot(x^2,(x,-2,2),color="purple")
skinny = plot(4*x^2,(x,-2,2),color="darkgreen")
regular + skinny
︡aa785756-16a9-4145-896a-4e7864790623︡{"file":{"filename":"/projects/a717257b-7b34-4f0a-bccc-47996d6ed607/.sage/temp/compute7-us/17920/tmp_lRqYA0.svg","show":true,"text":null,"uuid":"b9f5b4e2-c67c-4148-b99a-5165a185657d"},"once":false}︡{"done":true}︡
︠f40f181f-32e1-48ab-bc62-a94aea77d135i︠
%html
Problem: Plot a green $y=\sin(x)$ together with a red $y=2\cos(x)$. Note that you can use pi
as part of your range.
︡c376e496-dbea-4095-951b-f03598a23d80︡{"done":true,"html":"\nProblem: Plot a green $y=\\sin(x)$ together with a red $y=2\\cos(x)$. Note that you can use pi
as part of your range.\n"}
︠144ecb5a-e292-4752-8410-15dea4390f66︠
︡cd809d4c-98a1-4d86-9e86-35230a5c1692︡
︠7c62d995-9a29-4b88-ab19-c124afe89066i︠
%html
Boundaries of a plot can be specified, in addition to the overall size.
︡697e5e3a-5a20-4372-a965-060c593a14f4︡{"done":true,"html":"\nBoundaries of a plot can be specified, in addition to the overall size."}
︠2c2511ba-94ce-430e-8968-4751e602cba8s︠
plot(1+e^(-x^2),xmin=-2,xmax=2,ymin=0,ymax=2.5,figsize=10)
︡d814de56-a6c0-4699-8797-38b1bc76a4e9︡{"file":{"filename":"/projects/a717257b-7b34-4f0a-bccc-47996d6ed607/.sage/temp/compute7-us/17920/tmp_lYkRcC.svg","show":true,"text":null,"uuid":"ada46515-ec1e-4d6a-89d4-2e1db76f8100"},"once":false}︡{"done":true}︡{"done":true}︡
︠1fa628b3-5a08-4039-aa91-150ebf99b09ci︠
%html
Problem: Plot $y=5+3 \sin(4x)$ with suitable boundaries.
︡93bbd135-8fa6-4d19-bc02-b51eb49ed703︡{"done":true,"html":"\nProblem: Plot $y=5+3 \\sin(4x)$ with suitable boundaries."}
︠6cc22a80-25d0-49da-a17d-a1adab859a9d︠
︡a4e9113b-433d-4197-8517-bcaa384d831b︡
︠795073bf-22fd-4636-9fec-96743cb4020ai︠
%html
You can add lots of extra information.
︡ff8150f9-d3a7-46ef-8103-4de626f4624c︡{"done":true,"html":"\nYou can add lots of extra information."}
︠6e5b258f-9905-49dd-8a27-0a3d7ac2cc4cs︠
exponential = plot(1+e^(-x^2),xmin=-2,xmax=2,ymin=0,ymax=2.5)
max_line = plot(2,xmin=-2,xmax=2,ymin=0,ymax=2.5, linestyle="-.", color="red")
min_line = plot(1,xmin=-2,xmax=2,ymin=0,ymax=2.5, linestyle=":", color="magenta")
exponential + max_line + min_line
︡fe18462b-e628-4e71-953a-5f420bd0958e︡{"file":{"filename":"/projects/a717257b-7b34-4f0a-bccc-47996d6ed607/.sage/temp/compute7-us/17920/tmp_b3dPZ3.svg","show":true,"text":null,"uuid":"defa4be3-6d57-49c9-95bb-ff978fcc10c6"},"once":false}︡{"done":true}︡
︠45ac074b-6525-4baf-be51-0ba2e123efcei︠
%html
You can fill regions with transparent color, and thicken the curve. This example uses several such options.
︡b7263974-267b-4b11-ae1f-3af907914768︡{"done":true,"html":"\nYou can fill regions with transparent color, and thicken the curve. This example uses several such options."}
︠77ab76a6-24f4-4f63-b74d-2f4dd7767173s︠
exponential = plot(1+e^(-x^2),xmin=-2,xmax=2,ymin=0,ymax=2.5,fill=.5,fillcolor='grey',fillalpha=.3)
min_line = plot(1,xmin=-2,xmax=2,ymin=0,ymax=2.5, linestyle="-", thickness=6,color="magenta")
exponential + min_line
︡d424061d-52cf-42b0-b6ff-44552d08bfd7︡{"file":{"filename":"/projects/a717257b-7b34-4f0a-bccc-47996d6ed607/.sage/temp/compute7-us/17920/tmp_EyYjNC.svg","show":true,"text":null,"uuid":"7a17a0cc-1b66-4e5e-9ae4-6f9cc357dbed"},"once":false}︡{"done":true}︡
︠dbf248d9-e7ff-4948-9119-ef21141fd45ai︠
%html
You can also combine plots using the sum
function and list comprehension.
︡eb41cd6b-6247-44f4-bc43-1b4a1259fb91︡{"done":true,"html":"\nYou can also combine plots using the sum
function and list comprehension."}
︠35f3aa72-694e-4a06-80be-17215f1812c7s︠
sum([plot(x^n,(x,0,1), color=rainbow(5)[n]) for n in range(5)])
︡4fd0ee34-f1ef-45b7-a71a-d7463de0c3cc︡{"file":{"filename":"/projects/a717257b-7b34-4f0a-bccc-47996d6ed607/.sage/temp/compute7-us/17920/tmp_xC_IAZ.svg","show":true,"text":null,"uuid":"471b9799-3df7-4cf3-b6c9-d1b87e45f85a"},"once":false}︡{"done":true}︡
︠0782a8bd-53bb-4a62-b20a-b5ebbd2d067bi︠
%html
Problem:
Create a plot showing the cross-section area for the following solid of revolution problem: aspect_ratio
option (such options are also called keywords) to ensure the axes are correct for how we want to view this object.
︡efca1cf0-050b-48b3-ae12-44d3f4fefccc︡{"done":true,"html":"\naspect_ratio
option (such options are also called keywords) to ensure the axes are correct for how we want to view this object."}
︠4a5d1bca-7702-4bca-aaaf-1bbb2eb52294s︠
t=var('t')
parametric_plot([cos(t)+3*cos(t/9),sin(t)-3*sin(t/9)],(t,0,18*pi),fill=True,aspect_ratio=1)
︡3f68e36e-982a-49df-9fd2-935f1bcc7853︡{"file":{"filename":"/projects/a717257b-7b34-4f0a-bccc-47996d6ed607/.sage/temp/compute7-us/17920/tmp_tcL_kO.svg","show":true,"text":null,"uuid":"43997129-20c9-4732-838a-455a4f4bf8d9"},"once":false}︡{"done":true}︡
︠ff7d4362-8bd1-4dee-a9e8-7df91c661991i︠
%html
Problem:
The following parametric equations will create a so-called hypocycloid:
$$x(t) = 17*\cos(t)+3*\cos(17t/3)$$
$$y(t) = 17*\sin(t)-3*\sin(17t/3)$$
Create this as a parametric plot.
︡f6b49a55-1952-45f1-b6fc-f38bacd7a941︡{"done":true,"html":"\nProblem:\nThe following parametric equations will create a so-called hypocycloid:\n $$x(t) = 17*\\cos(t)+3*\\cos(17t/3)$$\n $$y(t) = 17*\\sin(t)-3*\\sin(17t/3)$$\n Create this as a parametric plot."}
︠342aadee-1a85-4ada-9f9c-9b0e0a3e010e︠
︡79165055-d9b5-47d2-acf7-f4ba32b24475︡
︠a31fc253-b44b-4140-a637-8d1b3cc8b87di︠
%html
Sage automatically plots a 2D or 3D plot, a curve or a surface, depending on how many variables and coordinates you specify. Have a look at the following examples (move the 3D examples around).
︡d419009c-bd96-4cf4-8605-3d1bbcaf5a19︡{"done":true,"html":"\nSage automatically plots a 2D or 3D plot, a curve or a surface, depending on how many variables and coordinates you specify. Have a look at the following examples (move the 3D examples around)."}
︠a7f4c601-216c-40c6-9566-c618a192a802s︠
t=var('t')
parametric_plot([log(1+t^2),sin(t)],(t,0,pi))
︡7dddd809-78f8-4fdf-b5cb-01811bd72c48︡{"file":{"filename":"/projects/a717257b-7b34-4f0a-bccc-47996d6ed607/.sage/temp/compute7-us/17920/tmp_ai34MQ.svg","show":true,"text":null,"uuid":"e68e5a43-a9b2-481f-83ed-435cd8797d1f"},"once":false}︡{"done":true}︡
︠a508148b-e239-4109-bcbc-02dfda928544s︠
t=var('t')
parametric_plot3d([log(1+t^2),sin(t),cos(t)],(t,0,6*pi))
︡c049d77a-0473-4c83-8640-ba2a9012d7e6︡{"file":{"filename":"e213be43-e476-4d93-85a3-8614d1a92098.sage3d","uuid":"e213be43-e476-4d93-85a3-8614d1a92098"}}︡{"done":true}︡
︠515bbc2a-bff7-404b-9847-195b9033c922s︠
t,r=var('t,r')
parametric_plot([log(1+t^2),sin(r*t),cos(r*t)],(t,0,pi),(r,-1,1))
︡1c4f7545-b9b4-403b-b550-74fe251ac506︡{"file":{"filename":"b7d0b313-8407-47ff-be4e-65e40850996f.sage3d","uuid":"b7d0b313-8407-47ff-be4e-65e40850996f"}}︡{"done":true}︡
︠c9f609cb-b6ca-4c28-af22-9f20f7b79e30i︠
%html
Problem: A neat example where we can use parametric plots are Lissajous Curves. These are curves of the form
$$x(t) = \sin(a t) \qquad y(t)=\sin(b t)$$
where $t\in [0,2\pi]$ and $a$ and $b$ are some relatively prime natural numbers. Draw a few such Lissajous Curves, changing $a$ and $b$ and observing how the curve changes accordingly.
︡9115db8e-d542-4cc4-af1f-6a408473bda0︡{"done":true,"html":"\nProblem: A neat example where we can use parametric plots are Lissajous Curves. These are curves of the form \n $$x(t) = \\sin(a t) \\qquad y(t)=\\sin(b t)$$\nwhere $t\\in [0,2\\pi]$ and $a$ and $b$ are some relatively prime natural numbers. Draw a few such Lissajous Curves, changing $a$ and $b$ and observing how the curve changes accordingly.\n"}
︠7e8d0a8f-650b-42ce-976c-f98aff2f39dc︠
︡9c08ec1a-e2ee-4ff2-852e-10921d783ea2︡
︠49bf4d64-b807-48b5-87aa-e049e80a11cd︠
︡17e09b22-5863-4b0f-a3b4-ca2c8927a35d︡
︠52d3f570-1c54-4cc6-8dd4-6268e1af2df3i︠
%html